package logic

import (
	"context"
	"house_srv/mysql"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderShowLogic {
	return &OrderShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderShowLogic) OrderShow(in *house.OrderShowRequest) (*house.OrderShowResponse, error) {
	// todo: add your logic here and delete this line
	order := mysql.Order{}
	err := order.OrderInfo(in.OrderId)
	if err != nil {
		return nil, err
	}
	return &house.OrderShowResponse{
		UserId:      int64(order.UserId),
		OrderSn:     order.OrderSn,
		PayType:     int64(order.PayType),
		PayTime:     int64(order.PayTime),
		Amount:      order.Amount,
		OrderStatus: int64(order.OrderStatus),
	}, nil
}
